package com.mylove.judas.yaya.common.rx.subscriber;


import android.content.Context;

import com.mylove.judas.yaya.common.rx.RxErrorHandler;

import io.reactivex.annotations.NonNull;
import io.reactivex.disposables.Disposable;

/**
 * Created by Administrator on 2017/5/27 0027.
 */
public abstract class ProgressDialogSubscriber<T> extends ErrorHandlerSubscriber<T> {

    private Context context;

    public ProgressDialogSubscriber(Context context) {
        super(new RxErrorHandler(context));
        this.context = context;
    }

    @Override
    public void onSubscribe(@NonNull Disposable d) {

        showProgressDialog();
    }

    @Override
    public void onComplete() {
        dismissProgressDialog();
    }

    @Override
    public void onError(Throwable t) {
        dismissProgressDialog();
        super.onError(t);
    }

    public boolean isShowDialog(){
        return false;
    }


    public void showProgressDialog(){

        if (isShowDialog()) {
            // showdialog
//            context.sendBroadcast();
        }

    }

    public void dismissProgressDialog(){

        if (isShowDialog()) {// && dialog.isShowing();
            //closedialog
        }

    }

}
